<?php include "include/header.php" ?>
<div class="main-content">
					<div class="container">
										
						<div class="page-content">
						
							<!-- Heading -->
							<div class="single-head">
								<!-- Heading -->
								<h3 class="pull-left"><i class="fa fa-tags green"></i> User</h3>
								<!-- Bread crumbs -->
								<div class="breads pull-right">
									<strong>Nav</strong> : <a href="<?=base_url('/')?>">Home</a> / <a href="<?=base_url('user/user_edit')?>">User</a>
								</div>
								<div class="clearfix"></div>
							</div>
							
							<!-- Posts page -->
							<div class="page-posts">
								<!-- Nav tabs -->
								<div class="page-tabs">
									<ul class="nav nav-tabs">
										<li class="active"><a href="#posts" class="br-lblue" data-toggle="tab"><i class="fa fa-tags lblue"></i> Users</a></li>
										<li><a href="#postnew" class="br-red" data-toggle="tab"><i class="fa fa-tag red"></i> Add Users</a></li>
									</ul>
									<!-- Tab panes -->
									<div class="tab-content">
										<div class="tab-pane fade active in" id="posts">
											<div class="table-responsive">
												<form id="user_form">
													<table class="table table-bordered">
														<thead>
															<tr>
																<th><input type="checkbox" name="tablechoice" onclick="var ck = this.checked;$(':checkbox').each(function(){this.checked = ck});"/></th>
																<th>User_name</th>
																<th>Role_id</th>
																<th>Edits</th>
															</tr>
														</thead>
														<tbody>														
															<?php foreach ( $user_infos as $row ) { ?>
																<tr>
																	<td class="ui"><input type="checkbox" name="user_id" value="<?=$row['user_id']?>"/></td>
																	<td class="un"><?=$row['user_name']?></td>
																	<td class="ri"><?=$row['role_id']?></td>
																	<td>
																		<a data-toggle="modal" href="#user_update" class="btn btn-xs btn-danger user_edit"><i class="fa fa-pencil"></i></a>																		
																		<a class="btn btn-xs btn-success user_del" onclick="confirm('Are you sure to delete?',function(flag){if(flag){location.href='<?=base_url('user/delete')?>?user_id=<?=$row['user_id']?>'}})" href="javascript:;"><i class="fa fa-trash-o"></i> </a>
																	</td>
																</tr>
															<?php } ?>
														</tbody>
													</table>
												</form>
											</div><!-- Table responsive end -->
										<!--
											<ul class="pagination pull-right">
												<li><a href="#">&laquo;</a></li>
												<li><a href="#">1</a></li>
												<li><a href="#">2</a></li>
												<li><a href="#">3</a></li>
												<li><a href="#">4</a></li>
												<li><a href="#">5</a></li>
												<li><a href="#">&raquo;</a></li>
											</ul>-->
											<div class="clearfix"></div>
										</div>
										<div class="tab-pane fade" id="postnew">
											<!-- Heading -->
											<h4>Add User</h4>	
											<form class="form-horizontal" role="form" method="post" action="<?=base_url('user/add')?>">
												<!-- Post title area -->
												<div class="form-group">
													<label for="title" class="col-md-2 control-label">User Name</label>
													<div class="col-md-10">
														<input type="text" name="user_name" class="form-control" id="title" placeholder="Enter User Name">
													</div>
												</div>
												<!-- Post tag area -->
												<div class="form-group">
													<label for="tag" class="col-md-2 control-label">Password</label>
													<div class="col-md-10">
														<input type="text" name="password" class="form-control" id="title" placeholder="Enter Password">
													</div>
												</div>
												<!-- Post tag area -->
												<div class="form-group">
													<label for="tag" class="col-md-2 control-label">Role Id</label>
													<div class="col-md-10">
														<input type="text" name="role_id" class="form-control" id="title" placeholder="Enter Role Id">
													</div>
												</div>
												
												<!-- Button -->
												<div class="form-group">
													<div class="col-md-offset-2 col-md-10">
													<div class="pull-right">
														<!-- Buttons -->
														<input type="submit" class="btn btn-default" value="add" />
													</div>
													<div class="clearfix"></div>
												</div>
											</form>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div> <!-- Posts page end -->
							<!-- report update form -->
							<div class="modal fade" id="user_update" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
								<div class="modal-dialog">
								    <div class="modal-content">    
					 			        <div class="modal-header">
									        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
										        <h4 class="modal-title" id="exampleModalLabel">Update User</h4>
										</div>
									    <div class="modal-body">
										    <form class="form-horizontal" role="form" method="post" action="<?=base_url('user/update')?>">
										    	<input type="checkbox" name="user_id" id="user_id" checked="checked" hidden>
										        <div class="form-group">
													<label for="title" class="col-md-2 control-label">User Name</label>
													<div class="col-md-10">
														<input type="text" name="user_name" class="form-control" id="user_name" placeholder="Enter User Name">
													</div>
												</div>
												<!-- Post tag area -->
												<div class="form-group">
													<label for="tag" class="col-md-2 control-label">Password</label>
													<div class="col-md-10">
														<input type="text" name="password" class="form-control" id="password" placeholder="Enter Password">
													</div>
												</div>
												<!-- Post tag area -->
												<div class="form-group">
													<label for="tag" class="col-md-2 control-label">Role Id</label>
													<div class="col-md-10">
														<input type="text" name="role_id" class="form-control" id="role_id" placeholder="Enter Role Id">
													</div>
												</div>
												<button type="submit" class="btn btn-info btn-block">Update</button>
										    </form>
										</div>
										<div class="clearfix"></div>
										<div class="modal-footer">
										    
									    </div>
								    </div>
						        </div>
							</div>
							<!-- report update form -->
						</div>
						
					</div>
				</div>
				</div>
			<!-- Mainbar ends -->
			
			<div class="clearfix"></div>
		</div>
<?php include "include/js.php" ?>
<!-- script for this page -->
<script>
$(document).ready(function(){
	
	$("#user_update").on('show.bs.modal', function (event) {
		var button = $(event.relatedTarget);
		var user_id = button.parent().prevAll(".ui").children().val();
		var user_name = button.parent().prevAll(".un").text();
		var password = button.parent().prevAll(".ps").text();
		var role_id = button.parent().prevAll(".ri").text();
		var modal = $(this);
		modal.find('#user_id').val(user_id);
  		modal.find('#user_name').val(user_name);
  		modal.find('#password').val(password);
  		modal.find('#role_id').val(role_id);
	});	
});           
</script>
<?php include "include/footer.php" ?>